package com.study.example.controller;

import com.study.example.component.RandomComponent;
import com.study.example.domain.Man;
import com.study.example.domain.ManRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

/**
 * Created by User on 2017/9/13.
 */
@RestController
public class JpaController {

    @Autowired
    private ManRepository manRepository;
    @Autowired
    private RandomComponent randomComponent;


    @RequestMapping("/insert")
    public String insert() {
        manRepository.save(new Man()
                .setPower(randomComponent.nextInt(2000))
                .setUserName("username" + randomComponent.nextInt(2000))
                .setEmail(randomComponent.nextInt(2000) + "@qq.com")
                .setPassWord(randomComponent.nextInt(2000) + "")
                .setNickName("nickname" + randomComponent.nextInt(2000))
                .setRegTime(new Date().toString()));

        return "success";
    }

}
